package com.cesgroup.zw.spring.boot.library.echarts.pictorialBar.complex;

import com.cesgroup.zw.spring.boot.echarts.component.series.PictorialBar;
import com.cesgroup.zw.spring.boot.echarts.enums.Align;
import com.cesgroup.zw.spring.boot.echarts.enums.Easing;
import com.cesgroup.zw.spring.boot.echarts.enums.Position;
import com.cesgroup.zw.spring.boot.echarts.enums.Symbol;
import com.cesgroup.zw.spring.boot.echarts.model.style.ItemStyle;
import com.cesgroup.zw.spring.boot.echarts.model.style.LabelStyle;

/**
 * @author ytj
 * @date 2019/7/8 15:36
 */
@SuppressWarnings("serial")
public class PictorialBarComplexSeries extends PictorialBar{
    public PictorialBarComplexSeries(PictorialBarComplexParam param,String type){
        if("outer".equals(type))
            this.outer(param);
        else if("withIn".equals(type))
            this.withIn(param);
        else if("current".equals(type))
            this.current(param);
        else if("full".equals(type))
            this.full(param);
    }
    public void outer(PictorialBarComplexParam param){
        this.setType("pictorialBar");
        this.setSymbol(Symbol.reat);
        this.setSymbolOffset(new Object[]{"-1%",0});
        this.setSymbolSize(new Object[]{"102%",24});
        this.setItemStyle(new ItemStyle(){{
            this.setColor("rgba(54,215,182,0.27)");
        }});
        this.setZ(-180);
        this.setSymbolRepeat(null);
        this.setSymbolBoundingData(2000);
        this.setAnimationEasing(Easing.elasticOut);
        this.setData(param.getDataset().get("data"));
    }
    public void withIn(PictorialBarComplexParam param){
        this.setType("pictorialBar");
        this.setSymbol(Symbol.reat);
        this.setSymbolOffset(new Object[]{"-0.5%",0});
        this.setSymbolSize(new Object[]{"101%",22});
        this.setItemStyle(new ItemStyle(){{
            this.setColor("black");
        }});
        this.setZ(-20);
        this.setSymbolRepeat(null);
        this.setSymbolBoundingData(2000);
        this.setAnimationEasing(Easing.elasticOut);
        this.setData(param.getDataset().get("data"));
    }
    public void current(PictorialBarComplexParam param){
        this.setType("pictorialBar");
        this.setSymbol(Symbol.rect);
        this.setItemStyle(new ItemStyle(){{
            this.setBarBorderRadius(5);
            this.setColor("#36d7b6");
        }});
        this.setSymbolRepeat("fixed");
        this.setSymbolMargin("5%");
        this.setSymbolClip(true);
        this.setSymbolSize(20);
        this.setSymbolBoundingData(2000);
        this.setZ(99999999);
        this.setAnimationEasing(Easing.elasticOut);
        this.setAnimationDelay("function(dataIndex, params) { return params.index * 30; }");
        this.setData(param.getDataset().get("data"));
    }
    public void full(PictorialBarComplexParam param){
        this.setType("pictorialBar");
        this.setItemStyle(new ItemStyle(){{
            this.setColor("rgba(54,215,182,0.27)");
        }});
        this.setLabel(new LabelStyle(){{
            this.setShow(true);
            this.setFormatter("function(params) { return (params.value); }");
            this.setPosition(Position.right);
            this.setOffset(new Integer[]{10,0});
            this.setColor("darkorange");
            this.setFontSize(18);
        }});
        this.setAnimationDuration(0);
        this.setSymbolRepeat("fixed");
        this.setSymbolMargin("5%");
        this.setSymbol(Symbol.rect);
        this.setSymbolSize(20);
        this.setSymbolBoundingData(2000);
        this.setZ(99999);
        this.setAnimationEasing(Easing.elasticOut);
        this.setAnimationDelay("function(dataIndex, params) { return params.index * 30; }");
        this.setData(param.getDataset().get("data"));
    }
}
